﻿using System;
using System.Collections.Generic;
using System.Text;
using BF.IBLL.IXZCF_WS_ZJBCCLJDSBLLLibrary;
using BF.Infrastructure;
using BF.IDAL.IXZCF_WS_ZJBCCLJDSDALLibrary;
using BF.Model;
using System.Linq.Expressions;
using System.Linq;

namespace BF.BLL.XZCF_WS_ZJBCCLJDSBLLLibrary
{
    public class XZCF_WS_ZJBCCLJDSBLL : IXZCF_WS_ZJBCCLJDSBLL
    {
        private readonly IXZCF_WS_ZJBCCLJDSDAL iDal;
        private readonly IUnitOfWork<WSJD_BaseFrameworkEntities> uwork;
        public XZCF_WS_ZJBCCLJDSBLL(
            IUnitOfWork<WSJD_BaseFrameworkEntities> uwork, 
            IXZCF_WS_ZJBCCLJDSDAL iDal)
        {
            this.iDal = iDal;
            this.uwork = uwork;
        }

        #region IXZCF_WS_ZJBCCLJDSBLL 成员

        public bool Add(XZCF_WS_ZJBCCLJDS entity)
        {
           iDal.Add(entity);
		   int count = uwork.Commit();
            if (count > 0)
                return true;
            else
                return false;
        }

        public bool Delete(XZCF_WS_ZJBCCLJDS entity)
        {
            iDal.Delete(entity);
            int count = uwork.Commit();
            if (count > 0)
                return true;
            else
                return false;
        }

        public bool Delete(Expression<Func<XZCF_WS_ZJBCCLJDS, bool>> predicate)
        {
            iDal.Delete(predicate);
            int count = uwork.Commit();
            if (count > 0)
                return true;
            else
                return false;
        }


        public List<XZCF_WS_ZJBCCLJDS> GetList(
            Expression<Func<XZCF_WS_ZJBCCLJDS, bool>> where, 
            Expression<Func<XZCF_WS_ZJBCCLJDS, object>> orderBy, 
            PageModel pageModel, 
            bool isAscending)
        {
            return iDal.GetList(where, orderBy, pageModel, isAscending);
        }

        public List<XZCF_WS_ZJBCCLJDS> GetList(Expression<Func<XZCF_WS_ZJBCCLJDS, bool>> where)
        {
            return iDal.GetList(where);
        }

        public int GetRowCount(Expression<Func<XZCF_WS_ZJBCCLJDS, bool>> where)
        {
            return iDal.GetRowCount(where);
        }

        public bool Update()
        {
            int count = uwork.Commit();
            if (count > 0)
                return true;
            else
                return false;
        }

		public XZCF_WS_ZJBCCLJDS GetModel(Expression<Func<XZCF_WS_ZJBCCLJDS, bool>> predicate)
        {
            return iDal.GetModelByCondition(predicate);
        }
        #endregion
    }
}
